import random
import string
import itertools

def generate_isp_pattern_passwords():
    """生成运营商常见密码模式"""
    passwords = set()
    
    # 常见前缀
    prefixes = ['CMCC', 'CHINA', 'MOBILE', 'UNICOM', 'TELECOM', 'CU', 'CT', 'CM']
    
    # 生成所有可能的4位数字组合
    for prefix in prefixes:
        if len(prefix) <= 4:  # 如果前缀小于等于4位
            remain_length = 8 - len(prefix)
            # 添加数字后缀
            for i in range(10 ** remain_length):
                num = str(i).zfill(remain_length)
                passwords.add(f"{prefix}{num}")
                passwords.add(f"{prefix.lower()}{num}")
    
    # 生成8位大写字母组合（重点是CMCC/CUCC等运营商缩写的变体）
    patterns = [
        'CMCC####',
        'CUCC####',
        'CTCC####',
        'CU######',
        'CT######',
        'CM######'
    ]
    
    for pattern in patterns:
        digit_positions = [i for i, char in enumerate(pattern) if char == '#']
        letters_part = ''.join(c for c in pattern if c != '#')
        
        # 为每个#生成0-9的数字
        for nums in itertools.product('0123456789', repeat=len(digit_positions)):
            pwd = list(letters_part + '0' * len(digit_positions))
            for pos, num in zip(digit_positions, nums):
                pwd[pos] = num
            passwords.add(''.join(pwd))

    # 添加一些随机的8位大小写字母组合
    while len(passwords) < 1000:
        pwd = ''.join(random.choices(string.ascii_letters, k=8))
        passwords.add(pwd)

    return passwords

def main():
    # 生成运营商风格的密码
    isp_passwords = generate_isp_pattern_passwords()
    
    # 写入文件
    with open('isp_password_dict.txt', 'w', encoding='utf-8') as f:
        f.write('\n'.join(sorted(isp_passwords)))

    print(f"已生成运营商密码字典，共 {len(isp_passwords)} 个密码")
    print("密码示例:")
    for pwd in list(isp_passwords)[:10]:
        print(f"- {pwd}")

if __name__ == '__main__':
    main() 